<template>
  <div class="home">
    <p>{{ username }}</p>
    <el-button @click="testApi">fetchData</el-button>
  </div>
</template>

<script>
import { mapState } from "vuex";
import { getInfo } from "../api/user";
export default {
  name: "Home",
  mounted() {
    this.getUserInfo();
  },
  computed: {
    ...mapState({
      username: (state) => state.app.user.username,
    }),
    // ...mapGetters(['example'])
  },
  methods: {
    async getUserInfo() {
      // const { data: res } = await this.$axios.get("/gyhlwSunshine");
      const { data: res } = await getInfo();
      console.log(res);
    },
    // 该方法仅供测试
    testApi() {
      console.log(process.env, process.env.VUE_APP_TEST);
      // this.$axios({ method: "get", url: "/asd", headers: { token: "123" } });
    },
  },
};
</script>
